package top.withwings.bonus;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import top.withwings.bonus.bonus.pojo.Good;
import top.withwings.bonus.bonus.service.GoodService;

@RunWith(SpringRunner.class)
@SpringBootTest
public class GoodsInit {

    @Autowired private GoodService goodService;

    @Test
    public void init(){
        saveNormalGood();
        saveClothes();
        saveFruits();
        saveFoods();




    }


    private void saveFruits(){
        Good bigApple = new Good();
        bigApple.setEnabled(true);
        bigApple.setCode("apple-400g");
        bigApple.setName("苹果");
        bigApple.setStandardPrice(2.8);
        bigApple.setSpecification("国光400g");
        goodService.create(bigApple);

        Good apple = new Good();
        apple.setEnabled(true);
        apple.setCode("apple");
        apple.setName("苹果");
        apple.setStandardPrice(1.8);
        apple.setSpecification("");
        goodService.create(apple);

        Good banana = new Good();
        banana.setEnabled(true);
        banana.setCode("banana");
        banana.setName("香蕉");
        banana.setStandardPrice(5.8);
        banana.setSpecification("都乐超甜");
        goodService.create(banana);

        Good orange = new Good();
        orange.setEnabled(true);
        orange.setCode("orange");
        orange.setName("橘子");
        orange.setStandardPrice(3.8);
        orange.setSpecification("");
        goodService.create(orange);



    }

    private void saveNormalGood(){
        Good laptop = new Good();
        laptop.setEnabled(true);
        laptop.setCode("laptop");
        laptop.setName("笔记本电脑");
        laptop.setStandardPrice(4000);
        laptop.setSpecification("");
        goodService.create(laptop);


        Good cellphone = new Good();
        cellphone.setEnabled(true);
        cellphone.setCode("iphone-x");
        cellphone.setName("手机");
        cellphone.setStandardPrice(8000);
        cellphone.setSpecification("苹果X");
        goodService.create(cellphone);

        Good ball = new Good();
        ball.setEnabled(true);
        ball.setCode("ball");
        ball.setName("篮球");
        ball.setStandardPrice(20);
        ball.setSpecification("");
        goodService.create(ball);


        Good pen = new Good();
        pen.setEnabled(true);
        pen.setCode("pencil");
        pen.setName("铅笔");
        pen.setStandardPrice(0.5);
        pen.setSpecification("HB");
        goodService.create(pen);


        Good paper = new Good();
        paper.setEnabled(true);
        paper.setCode("paper");
        paper.setName("打印纸");
        paper.setStandardPrice(35);
        paper.setSpecification("");
        goodService.create(paper);

        Good puzzle = new Good();
        puzzle.setEnabled(true);
        puzzle.setCode("puzzle");
        puzzle.setName("拼图");
        puzzle.setStandardPrice(35);
        puzzle.setSpecification("");
        goodService.create(puzzle);

        Good mic = new Good();
        mic.setEnabled(true);
        mic.setCode("micro-phone");
        mic.setName("麦克风");
        mic.setStandardPrice(1135);
        mic.setSpecification("电容增强型");
        goodService.create(mic);
    }

    private void saveFoods() {

        Good beer = new Good();
        beer.setEnabled(true);
        beer.setCode("QD-BEER");
        beer.setName("青岛啤酒");
        beer.setStandardPrice(6.5);
        beer.setSpecification("");
        goodService.create(beer);

        Good biscuit = new Good();
        biscuit.setEnabled(true);
        biscuit.setCode("QD-BISCUIT");
        biscuit.setName("青岛钙奶饼干");
        biscuit.setStandardPrice(3.5);
        biscuit.setSpecification("");
        goodService.create(biscuit);

        Good bigMilk = new Good();
        bigMilk.setEnabled(true);
        bigMilk.setCode("MILK-1L");
        bigMilk.setName("盒装牛奶");
        bigMilk.setStandardPrice(10.5);
        bigMilk.setSpecification("1L");

        goodService.create(bigMilk);
        Good smallMilk = new Good();
        smallMilk.setEnabled(true);
        smallMilk.setCode("MILK-250ml");
        smallMilk.setName("盒装牛奶");
        smallMilk.setStandardPrice(3.5);
        smallMilk.setSpecification("250ml");
        goodService.create(smallMilk);
        Good popCorn = new Good();
        popCorn.setEnabled(true);
        popCorn.setCode("POP-CORN");
        popCorn.setName("爆米花");
        popCorn.setStandardPrice(5);
        popCorn.setSpecification("");
        goodService.create(popCorn);

    }


    private void saveClothes() {

        Good dress = new Good();
        dress.setEnabled(true);
        dress.setCode("dress");
        dress.setName("长裙");
        dress.setStandardPrice(96);
        dress.setSpecification("");
        goodService.create(dress);


        Good skirt = new Good();
        skirt.setEnabled(true);
        skirt.setCode("skirt");
        skirt.setName("短裙");
        skirt.setStandardPrice(46);
        skirt.setSpecification("均码");
        goodService.create(skirt);


        Good miniSkirt = new Good();
        miniSkirt.setEnabled(true);
        miniSkirt.setCode("miniSkirt");
        miniSkirt.setName("超短裙");
        miniSkirt.setStandardPrice(66);
        miniSkirt.setSpecification("均码");
        goodService.create(miniSkirt);


        Good bigShirt = new Good();
        bigShirt.setEnabled(true);
        bigShirt.setCode("shirt-L");
        bigShirt.setName("衬衫");
        bigShirt.setStandardPrice(50);
        bigShirt.setSpecification("大号");
        goodService.create(bigShirt);

        Good shirt = new Good();
        shirt.setEnabled(true);
        shirt.setCode("shirt-M");
        shirt.setName("衬衫");
        shirt.setStandardPrice(50);
        shirt.setSpecification("中号");
        goodService.create(shirt);

        Good smallShirt = new Good();
        smallShirt.setEnabled(true);
        smallShirt.setCode("shirt-S");
        smallShirt.setName("衬衫");
        smallShirt.setStandardPrice(50);
        smallShirt.setSpecification("小号");
        goodService.create(smallShirt);
    }

}
